<?php

namespace StudyBuddy\Modules\Tumblr;

/**
 * Class repsesents on blog post to be
 * sent to Tumblr Blog
 *
 */
class TumblrPost extends TumblrContent {

    /**
     * Title of blog post
     *
     * @var string
     */
    protected $title = '';

    /**
     * Body of blog post
     * may contain html
     *
     * @var string
     */
    protected $body = '';

    /**
     * string to make SEO-friendly url
     *
     * @var string
     */
    protected $slug = '';

    /**
     * Comma-separated tags
     *
     * @var string
     */
    protected $tags = '';

    /**
     * (non-PHPdoc)
     * @see StudyBuddy\Modules\Tumblr.TumblrContent::getType()
     */
    public function getType() {
        return 'regular';
    }

    /**
     * Setter for $this->title
     *
     * @param string $s title of blog post
     * @throws \InvalidArgumentException if $s not a string
     * @return object $this
     */
    public function setTitle($s) {
        if (!is_string($s)) {
            throw new \InvalidArgumentException('$s must be a string. Was: ' . gettype($s));
        }

        $this->title = $s;

        return $this;
    }

    /**
     * Getter for $this->title
     * @return string
     */
    public function getTitle() {
        return $this->title;
    }

    /**
     * Getter for $this->body
     * @return string of blog post body (may be html)
     */
    public function getBody() {
        return $this->body;
    }

    /**
     * Getter for this->tags
     *
     * @return string comma separated list of tags
     * or empty string if there are no tags
     */
    public function getTags() {
        return $this->tags;
    }

    /**
     * Getter for $this->slug
     *
     * @return string
     */
    public function getSlug() {
        return $this->slug;
    }

    /**
     * Setter for $this->body
     *
     * @param string $s
     * @throws \InvalidArgumentException if input not a string
     *
     * @return object $this
     */
    public function setBody($s) {
        if (!is_string($s)) {
            throw new \InvalidArgumentException('$s must be a string. Was: ' . gettype($s));
        }

        $this->body = $s;

        return $this;
    }

    /**
     * Setter for $this->tags
     *
     * @param array $a array of tags
     *
     * @return object $this
     */
    public function setTags(array $a) {

        $this->tags = implode(',', $a);
        d('$this->tags: ' . $this->tags);

        return $this;
    }

    /**
     * Setter for $this->slug
     *
     * @param string $s
     * @throws \InvalidArgumentException if input not a string
     *
     * @return object $this
     */
    public function setSlug($s = '') {
        if (!is_string($s)) {
            throw new \InvalidArgumentException('$s must be a string. Was: ' . gettype($s));
        }

        $this->slug = $s;

        return $this;
    }

}
